<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="订单编号" prop="aftOrderCode">
        <el-input
          v-model="queryParams.aftOrderCode"
          placeholder="请输入订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="售后编号" prop="aftCode">
        <el-input
          v-model="queryParams.aftCode"
          placeholder="请输入售后编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品编码" prop="aftGoodName">
        <el-select v-model="queryParams.aftGoodName" placeholder="请选择发货物流状态" clearable>
          <el-option
            v-for="dict in dict.type.GOOD_CODE"
            :key="dict.label"
            :label="dict.value"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!--
      <el-form-item label="售后原因" prop="aftReason">
        <el-input
          v-model="queryParams.aftReason"
          placeholder="请输入售后原因"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="售后申请时间" prop="aftApplyTime">
        <el-date-picker type="daterange" v-model="aftApplyTime" format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd" :style="{width: '100%'}" start-placeholder="开始日期" end-placeholder="结束日期"
                  range-separator="至" clearable></el-date-picker>
        <!-- <el-date-picker clearable
          v-model="queryParams.aftApplyTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择售后申请时间">
        </el-date-picker> -->
      </el-form-item>
      <!-- <el-form-item label="订单金额" prop="aftOrderPrice">
        <el-input
          v-model="queryParams.aftOrderPrice"
          placeholder="请输入订单金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="发货物流单号" prop="aftSendCode">
        <el-input
          v-model="queryParams.aftSendCode"
          placeholder="请输入发货物流单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="退货物流单号" prop="aftReturnCode" v-if="activeName=='thtk'">
        <el-input
          v-model="queryParams.aftReturnCode"
          placeholder="请输入退货物流单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="发货物流状态" prop="aftSendStatus">
        <el-select v-model="queryParams.aftSendStatus" placeholder="请选择发货物流状态" clearable>
          <el-option
            v-for="dict in dict.type.aft_return_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="发货物流状态" prop="aftSendStatus">
        <el-select v-model="queryParams.aftSendStatus" placeholder="请选择发货物流状态" clearable>
          <el-option
            v-for="dict in dict.type.aft_return_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="操作结果" prop="aftOptResult">
        <el-select v-model="queryParams.aftOptResult" placeholder="请选择操作结果" clearable>
          <el-option
            v-for="dict in dict.type.opt_result"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="时长" prop="aftTimes">
        <el-input
          v-model="queryParams.aftTimes"
          placeholder="请输入时长"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="时间截点" prop="aftSectionTime">
        <el-date-picker clearable
          v-model="queryParams.aftSectionTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择时间截点">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="时间考核" prop="aftCheck">
        <el-select v-model="queryParams.aftCheck" placeholder="请选择时间考核" clearable>
          <el-option
            v-for="dict in dict.type.time_check_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="退款金额" prop="aftReturnPrice">
        <el-input
          v-model="queryParams.aftReturnPrice"
          placeholder="请输入退款金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="退货盒数" prop="aftReturnNum">
        <el-input
          v-model="queryParams.aftReturnNum"
          placeholder="请输入退货盒数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="处理完成时间" prop="aftHandleTime">
        <el-date-picker clearable
          v-model="queryParams.aftHandleTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择处理完成时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="实退盒数" prop="aftReceiveNum">
        <el-input
          v-model="queryParams.aftReceiveNum"
          placeholder="请输入实退盒数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="售后标签" prop="aftTab">
        <el-select v-model="queryParams.aftTab" placeholder="请选择售后标签" clearable>
          <el-option
            v-for="dict in dict.type.aft_tab"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="售后状态" prop="aftReturnStatus">
        <el-select v-model="queryParams.aftReturnStatus" placeholder="请选择售后状态" clearable>
          <el-option
            v-for="dict in dict.type.return_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="核对状态" prop="aftCheckStatus">
        <el-select v-model="queryParams.aftCheckStatus" placeholder="请选择核对状态" clearable>
          <el-option
            v-for="dict in dict.type.check_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="物流结算状态" prop="aftSendCheckStatus">
        <el-select v-model="queryParams.aftSendCheckStatus" placeholder="请选择物流结算状态" clearable>
          <el-option
            v-for="dict in dict.type.send_exp_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="发货核对日期" prop="aftSendCheckData">
        <el-date-picker clearable
          v-model="queryParams.aftSendCheckData"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择发货物流核对日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="操作结果" prop="aftOptResultList">
        <MultipleSelect v-model="queryParams.aftOptResultList" :options="dict.type.opt_result" style="width: 250px;"></MultipleSelect>
      </el-form-item>
      <el-form-item label="异常数据" prop="isExp">
        <el-select v-model="queryParams.isExp" placeholder="请选择异常数据状态" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['aft:yfhjtk:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['aft:yfhjtk:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['aft:yfhjtk:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['aft:yfhjtk:export']"
        >导出</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
        >导入</el-button>
      </el-col>


      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImportExp"
        >物流单号导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-tabs type="border-card" v-model="activeName"  @tab-click="getList">

      <el-tab-pane label="已发货仅退款" name="yfhjtk">

        <el-table v-loading="loading" :data="yfhjtkList"  @selection-change="handleSelectionChange" :row-class-name="tableRowClassName"
        show-summary :summary-method="getSummaries">
          <el-table-column type="selection" width="55" align="center" />
          <!-- <el-table-column label="主键" align="center" prop="id" /> -->
          <!-- <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column> -->
          <el-table-column label="创建日期" align="center" prop="aftHandleTime" width="100">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="订单编号" align="center" prop="aftOrderCode" />
          <el-table-column label="售后编号" align="center" prop="aftCode" />
          <el-table-column label="商品编码" align="center" prop="aftGoodName"  width="100"/>
            <!-- <template slot-scope="scope">
              <div class="overflow" :title="scope.row.aftGoodName">{{scope.row.aftGoodName}}</div>
            </template>
          </el-table-column> -->
          <el-table-column label="售后原因" align="center" prop="aftReason">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.aft_reason" :value="scope.row.aftReason"/>
            </template>
          </el-table-column>
          <el-table-column label="订单金额" align="center" prop="aftOrderPrice" />

          <el-table-column label="商家退货地址" align="center" prop="aftReturnAddress">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.return_add" :value="scope.row.aftReturnAddress"/>
            </template>
          </el-table-column>
          <el-table-column label="发货物流单号" align="center" prop="aftSendCode" />
          <el-table-column label="发货物流状态" align="center" prop="aftSendStatus">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.aft_return_status" :value="scope.row.aftSendStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="操作结果" align="center" prop="aftOptResult">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.opt_result" :value="scope.row.aftOptResult"/>
            </template>
          </el-table-column>

          <el-table-column label="售后申请时间" align="center" prop="aftApplyTime" width="150">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.aftApplyTime, '{y}-{m}-{d} {h}:{m}') }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column label="时长" align="center" prop="aftTimes" /> -->
          <el-table-column label="时间截点" align="center" prop="aftSectionTime" width="150">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.aftSectionTime, '{y}-{m}-{d} {h}:{m}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="时间考核" align="center" prop="aftCheck">
            <template slot-scope="scope">
              <!-- <span  style="color: red;"  v-if="scope.row.aftCheck === '已超时'">{{scope.row.aftCheck}}</span> -->
              <span  v-if="scope.row.aftCheck === '0' || scope.row.aftCheck === '1'">
                <dict-tag :options="dict.type.time_check_status" :value="scope.row.aftCheck"/>
              </span>
              <!-- <span  v-else-if="scope.row.aftCheck === '1'">
                <dict-tag :options="dict.type.time_check_status" :value="scope.row.aftCheck"/>
              </span> -->
              <span  style="color: orange;font-size: 16px;"  v-else>{{scope.row.aftCheck}}</span>
            </template>

          </el-table-column>
          <el-table-column label="处理完成时间" align="center" prop="aftHandleTime" width="150">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.aftHandleTime, '{y}-{m}-{d} {h}:{m}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="退款金额" align="center" prop="aftReturnPrice" />
          <el-table-column label="发货件数" align="center" prop="aftReturnQuantity" />
          <el-table-column label="每件盒数" align="center" prop="aftReturnNum" />
          <el-table-column label="发货总盒数" align="center" prop="aftReturnTotalNum"  width="90"/>
          <el-table-column label="实退盒数" align="center" prop="aftReceiveNum" />
          <el-table-column label="售后标签" align="center" prop="aftTab">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.aft_tab" :value="scope.row.aftTab"/>
            </template>
          </el-table-column>
          <el-table-column label="售后备注" align="center" prop="aftReturnRemark" width="120">
            <template slot-scope="scope">
              <div class="overflow" :title="scope.row.aftReturnRemark">{{scope.row.aftReturnRemark}}</div>
            </template>
          </el-table-column>
          <el-table-column label="物流结算状态" align="center" prop="aftSendCheckStatus">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.send_exp_status" :value="scope.row.aftSendCheckStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="售后状态" align="center" prop="aftReturnStatus" width="100">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.return_status" :value="scope.row.aftReturnStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="核对状态" align="center" prop="aftCheckStatus">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.check_status" :value="scope.row.aftCheckStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['aft:yfhjtk:edit']"
              >修改</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['aft:yfhjtk:remove']"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />

      </el-tab-pane>

      <el-tab-pane label="退货退款" name="thtk">

        <el-table v-loading="loading" :data="yfhjtkList"  @selection-change="handleSelectionChange" :row-class-name="tableRowClassName"
        show-summary :summary-method="getSummaries">
          <el-table-column type="selection" width="55" align="center" />
          <!-- <el-table-column label="主键" align="center" prop="id" /> -->
          <!-- <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column> -->
          <el-table-column label="创建日期" align="center" prop="aftHandleTime" width="100">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="订单编号" align="center" prop="aftOrderCode" />
          <el-table-column label="售后编号" align="center" prop="aftCode" />
          <el-table-column label="商品编码" align="center" prop="aftGoodName" width="100"/>
           <!-- <template slot-scope="scope">
              <div class="overflow" :title="scope.row.aftGoodName">{{scope.row.aftGoodName}}</div>
            </template>
          </el-table-column> -->
          <el-table-column label="售后原因" align="center" prop="aftReason">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.aft_reason" :value="scope.row.aftReason"/>
            </template>
          </el-table-column>
          <el-table-column label="订单金额" align="center" prop="aftOrderPrice" />

          <el-table-column label="商家退货地址" align="center" prop="aftReturnAddress">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.return_add" :value="scope.row.aftReturnAddress"/>
            </template>
          </el-table-column>
          <el-table-column label="发货物流单号" align="center" prop="aftSendCode" />
          <el-table-column label="发货物流状态" align="center" prop="aftSendStatus">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.aft_return_status" :value="scope.row.aftSendStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="退货物流单号" align="center" prop="aftReturnCode" />
          <el-table-column label="操作结果" align="center" prop="aftOptResult">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.opt_result" :value="scope.row.aftOptResult"/>
            </template>
          </el-table-column>

          <el-table-column label="售后申请时间" align="center" prop="aftApplyTime" width="150">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.aftApplyTime, '{y}-{m}-{d} {h}:{m}') }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column label="时长" align="center" prop="aftTimes" /> -->
          <el-table-column label="时间截点" align="center" prop="aftSectionTime" width="150">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.aftSectionTime, '{y}-{m}-{d} {h}:{m}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="时间考核" align="center" prop="aftCheck">
            <template slot-scope="scope">
              <!-- <span  style="color: red;"  v-if="scope.row.aftCheck === '已超时'">{{scope.row.aftCheck}}</span> -->
              <span  v-if="scope.row.aftCheck === '0' || scope.row.aftCheck === '1'">
                <dict-tag :options="dict.type.time_check_status" :value="scope.row.aftCheck"/>
              </span>
              <!-- <span  v-else-if="scope.row.aftCheck === '1'">
                <dict-tag :options="dict.type.time_check_status" :value="scope.row.aftCheck"/>
              </span> -->
              <span  style="color: orange;font-size: 16px;"  v-else>{{scope.row.aftCheck}}</span>
            </template>

          </el-table-column>
          <el-table-column label="处理完成时间" align="center" prop="aftHandleTime" width="150">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.aftHandleTime, '{y}-{m}-{d} {h}:{m}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="退款金额" align="center" prop="aftReturnPrice" />
          <el-table-column label="发货件数" align="center" prop="aftReturnQuantity" />
          <el-table-column label="每件盒数" align="center" prop="aftReturnNum" />
          <el-table-column label="发货总盒数" align="center" prop="aftReturnTotalNum"  width="90"/>
          <el-table-column label="实退盒数" align="center" prop="aftReceiveNum" />
          <el-table-column label="售后标签" align="center" prop="aftTab">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.aft_tab" :value="scope.row.aftTab"/>
            </template>
          </el-table-column>
          <el-table-column label="售后备注" align="center" prop="aftReturnRemark" />
          <el-table-column label="物流结算状态" align="center" prop="aftSendCheckStatus">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.send_exp_status" :value="scope.row.aftSendCheckStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="售后状态" align="center" prop="aftReturnStatus"width="100">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.return_status" :value="scope.row.aftReturnStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="核对状态" align="center" prop="aftCheckStatus">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.check_status" :value="scope.row.aftCheckStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['aft:yfhjtk:edit']"
              >修改</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['aft:yfhjtk:remove']"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />

      </el-tab-pane>
    </el-tabs>
    <!-- 添加或修改已发货仅退款对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="160px">

        <el-row>
          <el-col :span="24">
          <div class="tableTitle"><span class="midText">订单信息</span></div>
          </br>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
           <el-form-item label="订单编号" prop="aftOrderCode">
             <el-input v-model="form.aftOrderCode" placeholder="请输入订单编号" v-if="optType == 'add'"/>
             <el-input v-model="form.aftOrderCode" placeholder="请输入订单编号" disabled v-else/>
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商品编码" prop="aftGoodName">
              <!-- <el-input v-model="form.aftGoodName" placeholder="请输入商品编码" v-if="optType == 'add'"/>
              <el-input v-model="form.aftGoodName" placeholder="请输入商品编码" disabled v-else/> -->

              <el-select v-model="form.aftGoodName" placeholder="请选择商品编码" v-if="optType == 'add'" @change="selectGoodCode">
                <el-option
                  v-for="dict in dict.type.GOOD_CODE"
                  :key="dict.value"
                  :label="dict.value"
                  :value="dict.value"
                ></el-option>
              </el-select>
              <el-select v-model="form.aftGoodName" placeholder="请选择商品编码" disabled v-else>
                <el-option
                  v-for="dict in dict.type.GOOD_CODE"
                  :key="dict.value"
                  :label="dict.value"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


          <el-row >
            <el-col :span="12">
              <el-form-item label="售后编号" prop="aftCode">
                <el-input v-model="form.aftCode" placeholder="请输入售后编号" v-if="optType == 'add'"/>
                <el-input v-model="form.aftCode" placeholder="请输入售后编号" disabled v-else/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="售后原因" prop="aftReason">
                <el-select v-model="form.aftReason" placeholder="请选择售后原因" v-if="optType == 'add' || form.aftReason == null || form.aftReason == ''">
                  <el-option
                    v-for="dict in dict.type.aft_reason"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
                <el-select v-model="form.aftReason" placeholder="请选择售后原因" disabled v-else>
                  <el-option
                    v-for="dict in dict.type.aft_reason"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>


          <el-row >
            <el-col :span="12">
             <el-form-item label="售后申请时间" prop="aftApplyTime">
               <el-date-picker clearable
                 v-model="form.aftApplyTime"
                 type="datetime"
                 format="yyyy/MM/dd HH:mm:ss"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 placeholder="请选择售后申请时间" v-if="optType == 'add'" @paste="handlePaste">
               </el-date-picker>
               <el-date-picker clearable
                 v-model="form.aftApplyTime"
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 placeholder="请选择售后申请时间" disabled v-else>
               </el-date-picker>
             </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="订单金额" prop="aftOrderPrice">
                <el-input v-model="form.aftOrderPrice" placeholder="请输入订单金额"/>
                <!-- <el-input v-model="form.aftOrderPrice" placeholder="请输入订单金额" disabled v-else/> -->
              </el-form-item>
            </el-col>
          </el-row>

        <el-row >
          <el-col :span="12">
           <el-form-item label="商家退货地址" prop="aftReturnAddress"> <!--  v-if="optType == 'add'" -->
             <el-select v-model="form.aftReturnAddress" placeholder="请选择商家退货地址">
               <el-option
                 v-for="dict in dict.type.return_add"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
               ></el-option>
           </el-select>

          <!-- <el-select v-model="form.aftReturnAddress" placeholder="请选择商家退货地址" disabled v-else>
             <el-option
               v-for="dict in dict.type.return_add"
               :key="dict.value"
               :label="dict.label"
               :value="dict.value"
             ></el-option>
           </el-select> -->
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发货物流公司名称" prop="aftSendCom">
              <el-select v-model="form.aftSendCom" placeholder="请选择发货物流公司名称">
                <el-option
                  v-for="dict in dict.type.express_com"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>

              <!-- <el-select v-model="form.aftSendCom" placeholder="请选择发货物流公司名称" disabled v-else>
                <el-option
                  v-for="dict in dict.type.express_com"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select> -->
            </el-form-item>
          </el-col>
        </el-row>


        <el-row >
          <el-col :span="12">
           <el-form-item label="发货物流单号" prop="aftSendCode">
             <el-input v-model="form.aftSendCode" placeholder="请输入发货物流单号" @input="selectExp"/>
             <!-- <el-input v-model="form.aftSendCode" placeholder="请输入发货物流单号" disabled v-else/> -->
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发货物流状态" prop="aftSendStatus">
              <el-select v-model="form.aftSendStatus" placeholder="请选择发货物流状态">
                <el-option
                  v-for="dict in dict.type.aft_return_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row >
          <el-col :span="12">
           <el-form-item label="时间截点" prop="aftSectionTime">
             <!-- <el-date-picker clearable
               v-model="form.aftSectionTime"
               type="datetime"
               value-format="yyyy-MM-dd HH:mm"
               placeholder="请选择时间截点" v-if="optType == 'add'">
             </el-date-picker> -->
             <el-date-picker clearable
               v-model="form.aftSectionTime"
               type="datetime"
               value-format="yyyy-MM-dd HH:mm"
               placeholder="请选择时间截点" disabled>
             </el-date-picker>
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="时间考核" prop="aftCheck">
              <el-select v-model="form.aftCheck" placeholder="请选择时间考核"  disabled>
                <el-option
                  v-for="dict in dict.type.time_check_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"

                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row >
          <el-col :span="12">
           <el-form-item label="操作结果" prop="aftOptResult">
             <el-select v-model="form.aftOptResult" placeholder="请选择操作结果">
               <el-option
                 v-for="dict in dict.type.opt_result"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
               ></el-option>
             </el-select>
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="售后类型" prop="aftKind">
              <el-select v-model="form.aftKind" placeholder="请选择售后类型" >
                <el-option
                  v-for="dict in dict.type.aft_kind"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>

              <!-- <el-select v-model="form.aftKind" placeholder="请选择售后类型" disabled v-else>
                <el-option
                  v-for="dict in dict.type.aft_kind"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
          <div class="tableTitle"><span class="midText">售后信息</span></div>
          </br>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
           <el-form-item label="处理完成时间" prop="aftHandleTime">
             <!-- <el-date-picker clearable
               v-model="form.aftHandleTime"
               type="datetime"
               value-format="yyyy-MM-dd HH:mm"
               placeholder="请选择处理完成时间" v-if="optType == 'add'">
             </el-date-picker> -->
             <el-date-picker clearable
               v-model="form.aftHandleTime"
               type="datetime"
               value-format="yyyy-MM-dd HH:mm"
               placeholder="请选择处理完成时间" disabled>
             </el-date-picker>
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款金额" prop="aftReturnPrice">
              <el-input v-model="form.aftReturnPrice" placeholder="请输入退款金额" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row v-if="activeName=='thtk'">
          <el-col :span="24">

            <el-form-item label="退货物流单号" prop="aftReturnCode">
              <el-input v-model="form.aftReturnCode" placeholder="请输退货物流单号" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row >
          <el-col :span="12">
           <el-form-item label="发货件数" prop="aftReturnQuantity">
             <el-input v-model="form.aftReturnQuantity" placeholder="请输入发货件数" @input="checkNum"/>
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单件盒数" prop="aftReturnNum">
              <el-input v-model="form.aftReturnNum" placeholder="请输入单件盒数" disabled/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row >
          <el-col :span="12">
           <el-form-item label="发货总盒数" prop="aftReturnTotalNum">
             <el-input v-model="form.aftReturnTotalNum" placeholder="请输入发货总盒数" disabled/>
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实退盒数" prop="aftReceiveNum">
              <el-input v-model="form.aftReceiveNum" placeholder="请输入实退盒数" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row >
          <el-col :span="12">
           <el-form-item label="售后标签" prop="aftTab">
             <el-select v-model="form.aftTab" placeholder="请选择售后标签">
               <el-option
                 v-for="dict in dict.type.aft_tab"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
               ></el-option>
             </el-select>
           </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="售后备注" prop="aftReturnRemark">
              <el-input v-model="form.aftReturnRemark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row >
          <el-col :span="12">
            <el-form-item label="售后状态" prop="aftReturnStatus">
              <el-select v-model="form.aftReturnStatus" placeholder="请选择售后状态" @change="checkReturnStatus">
                <el-option
                  v-for="dict in dict.type.return_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
           <el-form-item label="核对状态" prop="aftCheckStatus">
             <el-select v-model="form.aftCheckStatus" placeholder="请选择核对状态" @change="checkHandleStatus"
             v-if="form.aftReturnStatus !='0' && form.aftTab !=null && form.aftTab !=''">
               <el-option
                 v-for="dict in dict.type.check_status"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
               ></el-option>
             </el-select>
             <el-select v-model="form.aftCheckStatus" placeholder="请选择核对状态" @change="checkHandleStatus" disabled v-else>
               <el-option
                 v-for="dict in dict.type.check_status"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
               ></el-option>
             </el-select>
           </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 售后导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的售后数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 物流处理导入对话框 -->
    <el-dialog :title="uploadExp.title" :visible.sync="uploadExp.open" width="400px" append-to-body>
      <el-upload
        ref="uploadExp"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="uploadExp.headers"
        :action="uploadExp.url + '?updateSupport=' + uploadExp.updateSupport"
        :disabled="uploadExp.isUploading"
        :on-progress="handleFileUploadProgressExp"
        :on-success="handleFileSuccessExp"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!-- <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="uploadExp.updateSupport" /> 是否更新已经存在的售后数据
          </div> -->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplateExp">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileFormExp">确 定</el-button>
        <el-button @click="uploadExp.open = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listYfhjtk, getYfhjtk, delYfhjtk, addYfhjtk, updateYfhjtk,checkTime } from "@/api/aft/yfhjtk";
import { getToken } from "@/utils/auth";
import moment from 'moment';
import MultipleSelect from "@/components/MultipleSelect/MultipleSelect"

export default {
  name: "Yfhjtk",
  components: {
      MultipleSelect
  },
  dicts: ['aft_kind','time_check_status', 'check_status', 'return_status', 'aft_tab', 'express_com',
  'aft_return_status', 'opt_result','return_add','aft_reason','send_exp_status','GOOD_CODE','sys_yes_no'],
  data() {
    return {
      activeName:"yfhjtk",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 已发货仅退款表格数据
      yfhjtkList: [],
      // 弹出层标题
      title: "",
      //日期范围
      aftApplyTime: [],
      // 是否显示弹出层
      open: false,
      totalOrderPrice:0.00,//订单总金额
      totalReturnPrice:0.00,//退货金额
      aftReturnQuantity:0,//发货件数
      returnNum:0,//发货盒数
      aftReturnTotalNum:0,//发货总盒数
      receiveNum:0,//实际收到盒数(退货)
      allList:[],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        aftOrderCode: null,        aftCode: null,        aftGoodName: null,        aftReason: null,
        aftApplyTime: null,
        aftApplyTimeStart: null,
        aftApplyTimeEnd: null,
        aftKind: '',
                aftOrderPrice: null,        aftSendCode: null,        aftSendStatus: null,        aftOptResult: null,        aftTimes: null,        aftSectionTime: null,        aftCheck: null,        aftHandleTime: null,        aftReturnPrice: null,        aftReturnNum: null,        aftReceiveNum: null,        aftTab: null,        aftReturnRemark: null,        aftCheckStatus: null,        aftReturnStatus: null      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        aftOrderCode: [
          { required: true, message: "订单编码不能为空", trigger: "blur" }
        ],
        aftGoodName: [
          { required: true, message: "商品编码不能为空", trigger: "blur" }
        ],
        aftCode: [
          { required: true, message: "售后编号不能为空", trigger: "blur" }
        ],
        aftApplyTime: [
          { required: true, message: "售后时间不能为空", trigger: "blur" }
        ],
        aftReason: [
          { required: true, message: "售后原因不能为空", trigger: "blur" }
        ],
        aftReturnNum: [
          { required: true, message: "退货盒数不能为空", trigger: "blur" }
        ],
        aftKind: [
          { required: true, message: "售后类型不能为空", trigger: "blur" }
        ],
        aftReturnQuantity: [
          { required: true, message: "发货件数不能为空", trigger: "blur" }
        ],
        aftOrderPrice: [
          { required: true, message: "订单金额不能为空", trigger: "blur" }
        ],
        aftReturnAddress: [
          { required: true, message: "商家退货地址不能为空", trigger: "blur" }
        ],
        aftSendCom: [
          { required: true, message: "发货物流公司名称不能为空", trigger: "blur" }
        ],
        aftSendCode: [
          { required: true, message: "发货物流单号不能为空", trigger: "blur" }
        ],
        // aftReturnPrice: [
        //   { required: true, message: "退款金额不能为空", trigger: "blur" },
        //   { max: 10, message: '退款金额长度必须小于10个字符', trigger: 'blur' }
        // ],
        // aftReturnNum: [
        //   { required: true, message: "退货盒数不能为空", trigger: "blur" },
        //   { max: 10, message: '退货盒数长度必须小于10个字符', trigger: 'blur' }
        // ],
        // aftReceiveNum: [
        //   { required: true, message: "实际收到盒数(退货)不能为空", trigger: "blur" },
        //   { max: 10, message: '实际收到盒数(退货)长度必须小于10个字符', trigger: 'blur' }
        // ],
        // aftTab: [
        //   { required: true, message: "售后标签不能为空", trigger: "blur" },
        //   { max: 10, message: '售后标签长度必须小于10个字符', trigger: 'blur' }
        // ],
        // aftCheck: [
        //   { required: true, message: "时间考核不能为空", trigger: "blur" },
        //   { max: 10, message: '时间考核长度必须小于10个字符', trigger: 'blur' }
        // ],
        // aftSendStatus: [
        //   { required: true, message: "发货物流状态不能为空", trigger: "blur" },
        //   { max: 10, message: '发货物流状态长度必须小于10个字符', trigger: 'blur' }
        // ],
      },
      //计时器
      interval : null,

      //弹框的操作类型 view add edit
      optType: undefined,
      // 导入参数
      upload: {
        // 是否显示弹出层（导入）
        open: false,
        // 弹出层标题（导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/aft/yfhjtk/importData"
      },
      // 物流处理导入参数
      uploadExp: {
        // 是否显示弹出层（导入）
        open: false,
        // 弹出层标题（导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/aft/yfhjtk/importDataExp"
      },
    };
  },
  computed: {
      countdownItems() {
        //  var yfhjtks = null
        //  this.yfhjtkList.forEach(item => {
        //   // 使用 element 访问列表中的元素
        //   console.log(item);
        //   var time1 = new Date(item.aftSectionTime)
        //   var timeNow = new Date()
        //   var timeLong = 0
        //   timeLong = (timeNow-time1)/1000
        //   console.log(">>>>>time:",(timeNow-time1)/1000,"s")
        //   if(item.aftCheck == null && item.aftCheck == ""){
        //     item.aftCheck= Math.max(0, timeLong - 1)// 减少1秒，并确保不会变成负数
        //   }
        // });
        // yfhjtks = this.yfhjtkList
        // console.log("yfhjtks:",JSON.stringify(yfhjtks))
        // return yfhjtks;
        return this.yfhjtkList.map(item => ({
          ...item,
          // if(item.aftCheck == null && item.aftCheck == ""){
            // aftCheck:Math.max(0, 1000 - 1) // 减少1秒，并确保不会变成负数
            aftCheck: checkTime(item.aftCheck)
          // }
        }));

      }
    },
  mounted() {
    this.interval = setInterval(() => {
      this.yfhjtkList = this.countdownItems; // 更新所有倒计时数据
    }, 1000); // 每秒更新一次
  },
  created() {
    this.getList();
  },
  beforeDestroy() {
    clearInterval(this.interval); // 清除定时器以避免内存泄漏
  },
  methods: {

    /** 查询列表 */
    getList() {
      this.loading = true;
      if(this.aftApplyTime != undefined && this.aftApplyTime != null && this.aftApplyTime.length>0){
        this.queryParams.aftApplyTimeStart = this.aftApplyTime[0]
        this.queryParams.aftApplyTimeEnd = this.aftApplyTime[1]
      }
      if(this.activeName === 'yfhjtk'){
        this.queryParams.aftKind = '已发货仅退款'
      }else if(this.activeName === 'thtk'){
        this.queryParams.aftKind = '退货退款'
      }

      console.log("this.queryParams.aftReturnCode>>>>>",this.queryParams.aftReturnCode)
      listYfhjtk(this.queryParams).then(response => {
        this.yfhjtkList = response.data.rows;
        this.total = response.data.total;
        this.totalOrderPrice=response.totalOrderPrice//订单总金额
        console.log("totalOrderPrice>>>>>",this.totalOrderPrice)
        this.totalReturnPrice=response.totalReturnPrice//退货金额
        this.receiveNum=response.receiveNum//实际收到盒数(退货)
        this.returnNum=response.returnNum//发货盒数
        this.aftReturnQuantity=response.aftReturnQuantity//发货件数
        this.aftReturnTotalNum=response.aftReturnTotalNum//发货总盒数
        this.loading = false;
        if(this.yfhjtkList != null){
          this.yfhjtkList.forEach(yfhjtk =>{
            if(yfhjtk.aftCheck === null || yfhjtk.aftCheck === ''){
              const longTimes = (new Date(yfhjtk.aftSectionTime)-new Date()) //毫秒
              var tempStr = "";
              // console.log(JSON.stringify(longTimes),">>>>",(JSON.stringify(longTimes).indexOf("-") !== -1))
              if(Number(longTimes) < 0){
                yfhjtk.aftCheck = "0"//
              }else{
                //转换成HH:mm:ss
                const hours = Math.floor(longTimes / 3600000);
                const minutes = Math.floor((longTimes % 3600000) / 60000);
                const seconds = Math.floor((longTimes % 60000) / 1000);

                yfhjtk.aftCheck = hours+'时'+minutes+'分'+seconds+'秒'
              }

            }
          })
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,        remark: null,        status: "0",        delFlag: null,        createBy: null,        createTime: null,        updateBy: null,        updateTime: null,        aftOrderCode: null,        aftCode: null,        aftGoodName: null,        aftReason: null,        aftApplyTime: null,        aftOrderPrice: null,        aftReturnAddress: null,        aftSendCom: null,        aftSendCode: null,        aftSendStatus: null,        aftOptResult: null,        aftTimes: null,        aftSectionTime: null,        aftCheck: null,        aftHandleTime: null,        aftReturnPrice: null,        aftReturnNum: null,        aftReceiveNum: null,        aftTab: null,        aftReturnRemark: null,        aftCheckStatus: null,        aftReturnStatus: null      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      // if(this.queryParams.aftOptResult != null && this.queryParams.aftOptResult != ''){
      //   var aftOptResultStr = JSON.stringify(this.queryParams.aftOptResult)
      //   // aftOptResultStr = aftOptResultStr.replaceAll('"',"")
      //   // .replace(new RegExp(aftOptResultStr, '"'), "")
      //   // .replace("[","").replace("]","")

      //   this.queryParams.aftOptResultList = aftOptResultStr
      // }
      console.log("aftOptResult", this.queryParams.aftOptResult)
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      console.log("selection>>>>>",JSON.stringify(selection))
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    // 多选框选中数据
    selectGoodCode(code) {
      console.log("code>>>>>",JSON.stringify(code))
      let codeMap = this.dict.type.GOOD_CODE

      codeMap.forEach((item, key) => {
        console.log(key + " = " + JSON.stringify(item));
        if(code === item.value){
          this.form.aftReturnNum = item.label
          this.checkNum();
        }
      });
      // console.log("GOOD_CODE>>>>>>>",this.dict.type.GOOD_CODE)
    },
    //计算总盒数
    checkNum(){
      console.log(">>>>>>>>>")
      if(this.form.aftReturnQuantity != null && this.form.aftReturnQuantity != ''
      && this.form.aftReturnNum != null && this.form.aftReturnNum != ''){
        console.log(">>>>>>>>>",Number(this.form.aftReturnQuantity)*Number(this.form.aftReturnNum))
        this.form.aftReturnTotalNum = Number(this.form.aftReturnQuantity)*Number(this.form.aftReturnNum)
      }
    },
    //根据物流单号进行物流云仓筛选
    selectExp(){
      if(this.form.aftSendCode  != null && this.form.aftSendCode != ''){
        let code = this.form.aftSendCode
        let codeTop = code.substring(0,3)
        let codeJt = code.substring(0,2)
        if(codeTop === "770"){
          this.form.aftReturnAddress = 'xiongda'
          this.form.aftSendCom = 'shentong'
        }
        if(codeJt === 'JT' || codeJt === 'jt'){
          this.form.aftSendCom = 'jtexpress'
        }
      }
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.optType="add"
      if(this.activeName == 'yfhjtk'){
        this.title = "添加已发货仅退款";
        this.form.aftReturnAddress = 'online'
        this.form.aftKind="已发货仅退款"
      }else{
        this.title = "添加退货退款";
        this.form.aftReturnAddress = 'com'
        this.form.aftSendStatus = '0'
        this.form.aftKind="退货退款"
      }
      this.form.aftSendCom = 'jtexpress'
      // this.form.aftOrderPrice= 29.9
      this.form.aftCheckStatus = '0'

    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.optType="edit"
      const id = row.id || this.ids
      getYfhjtk(id).then(response => {
        this.form = response.data;
        this.open = true;
        if(this.activeName == 'yfhjtk'){
          this.title = "修改已发货仅退款";
        }else{
          this.title = "修改退货退款";
        }
        var aftSectionTime = new Date(row.aftSectionTime)
        var aftSectionTimeStr = aftSectionTime.getFullYear()+"-"+aftSectionTime.getMonth()+"-"+aftSectionTime.getDate()+" "+aftSectionTime.getHours()+":"+aftSectionTime.getMinutes()+":00"
        var today = new Date()
        var nowDateStr = today.getFullYear()+"-"+today.getMonth()+"-"+today.getDate()+" "+today.getHours()+":"+today.getMinutes()+":00"

        console.log("this.form.aftCheck>>>>",this.form.aftCheck)
        if((this.form.aftCheck == null || this.form.aftCheck == "") && new Date(aftSectionTimeStr) < new Date(nowDateStr)){
          this.form.aftCheck = '0'
        }
        if(this.form.aftCheckStatus === '1'){
          this.checkHandleStatus('1')
        }


      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {

            updateYfhjtk(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addYfhjtk(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除已发货仅退款编号为"' + row.aftOrderCode + '"的数据项？').then(function() {
        return delYfhjtk(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('aft/yfhjtk/export', {
        ...this.queryParams
      }, `yfhjtk_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "售后导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('aft/yfhjtk/importTemplate', {
      }, `aft_template_yfhjtk_${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    //////////////////////////

    /** 导入按钮操作 */
    handleImportExp() {
      this.uploadExp.title = "售后导入";
      this.uploadExp.open = true;
    },
    /** 下载模板操作 */
    importTemplateExp() {
      this.download('aft/yfhjtk/importTemplateExp', {
      }, `aft_template_yfhjtk_${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgressExp(event, file, fileList) {
      this.uploadExp.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccessExp(response, file, fileList) {
      this.uploadExp.open = false;
      this.uploadExp.isUploading = false;
      this.$refs.uploadExp.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileFormExp() {
      this.$refs.uploadExp.submit();
    },
    //变更背影颜色
    tableRowClassName({ row, rowIndex }) {
      var createTime = new Date(row.createTime)
      var createDate = createTime.getFullYear()+"-"+createTime.getMonth()+"-"+createTime.getDate()
      var today = new Date()
      var nowDate = today.getFullYear()+"-"+today.getMonth()+"-"+today.getDate()
      if(createDate === nowDate){
        return 'row1';
      }

    },
    //列表合计
    getSummaries(res){
      const { columns, data } = res
      // console.log("this.yfhjtkList>>>>",this.yfhjtkList);
      const sum = []

      columns.forEach((element, index) => {
        if (index == 1) {
          sum[index] = '合计'
        }
        if (index == 6) {
          //cur.wxAmount  合计对象的数字
           // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftOrderPrice), 0)
           // sum[index] = sum[index].toFixed(2)
           sum[index] = this.totalOrderPrice.toFixed(2)
        }
        if(this.activeName == 'thtk'){
          if (index == 16) {
            //cur.wxAmount  合计对象的数字
             // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftReturnPrice), 0)
             // sum[index] = sum[index].toFixed(2)
             sum[index] = this.totalReturnPrice.toFixed(2)
          }
          if (index == 17) {
            //cur.wxAmount  合计对象的数字
             // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftReturnNum), 0)
             // sum[index] = sum[index].toFixed(0)
             sum[index] = this.aftReturnQuantity
          }
          if (index == 19) {
            //cur.wxAmount  合计对象的数字
             // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftReturnNum), 0)
             // sum[index] = sum[index].toFixed(0)
             sum[index] = this.aftReturnTotalNum
          }
          if (index == 20) {
            //cur.wxAmount  合计对象的数字
             // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftReceiveNum), 0)
             // sum[index] = sum[index].toFixed(0)
             sum[index] = this.receiveNum
          }
        }else{
          if (index == 15) {
            //cur.wxAmount  合计对象的数字
             // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftReturnPrice), 0)
             // sum[index] = sum[index].toFixed(2)
             sum[index] = this.totalReturnPrice.toFixed(2)
          }
          if (index == 16) {
            //cur.wxAmount  合计对象的数字
             // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftReturnNum), 0)
             // sum[index] = sum[index].toFixed(0)
             sum[index] = this.aftReturnQuantity
          }
          if (index == 18) {
            //cur.wxAmount  合计对象的数字
             // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftReturnNum), 0)
             // sum[index] = sum[index].toFixed(0)
             sum[index] = this.aftReturnTotalNum
          }
          if (index == 19) {
            //cur.wxAmount  合计对象的数字
             // sum[index] = this.yfhjtkList.reduce((pre, cur) => pre + Number(cur.aftReceiveNum), 0)
             // sum[index] = sum[index].toFixed(0)
             sum[index] = this.receiveNum
          }
        }
      });
      return sum

    },

    checkReturnStatus(event){
      if(event === '1' ){
        this.form.aftCheckStatus = '1'
        this.checkHandleStatus('1')
      }else{
          this.form.aftCheckStatus = '0'
          this.checkHandleStatus('0')
          this.form.aftHandleTime = ''
      }
    },
    checkHandleStatus(event){

      if(event === '1' ){
        this.form.aftHandleTime = new Date()
        var aftSectionTime = new Date(this.form.aftSectionTime)
        var aftSectionTimeStr = aftSectionTime.getFullYear()+"-"+aftSectionTime.getMonth()+"-"+aftSectionTime.getDate()+" "+aftSectionTime.getHours()+":"+aftSectionTime.getMinutes()+":00"
        var today = new Date()
        var nowDateStr = today.getFullYear()+"-"+today.getMonth()+"-"+today.getDate()+" "+today.getHours()+":"+today.getMinutes()+":00"

        console.log("new Date(aftSectionTimeStr)>>>",new Date(aftSectionTimeStr),"|||||new Date(nowDateStr)>>>",new Date(nowDateStr))
        console.log("new Date(aftSectionTimeStr) > new Date(nowDateStr)>>>",(new Date(aftSectionTimeStr) > new Date(nowDateStr)))
        if(new Date(aftSectionTimeStr) > new Date(nowDateStr)){
          this.form.aftCheckStatus = '1'
          this.form.aftCheck = '1'
        }

        // if(this.form.aftReason == null || this.form.aftReason == ''){
        //   this.$set(this.rules,"aftReason",[{ required: true, message: "售后原因不能为空", trigger: "blur" },{ max: 10, message: '售后原因长度必须小于10个字符', trigger: 'blur' }])
        // }
        if(this.form.aftReturnPrice == null || this.form.aftReturnPrice == ''){
          this.$set(this.rules,"aftReturnPrice",[{ required: true, message: "退款金额不能为空", trigger: "blur" }])
        }
        // if(this.form.aftReturnNum == null || this.form.aftReturnNum == ''){
        //   this.$set(this.rules,"aftReturnNum",[{ required: true, message: "退货盒数不能为空", trigger: "blur" },{ max: 10, message: '退货盒数长度必须小于10个字符', trigger: 'blur' }])
        // }
        // if(this.form.aftReceiveNum == null || this.form.aftReceiveNum == ''){
        //   this.$set(this.rules,"aftReceiveNum",[{ required: true, message: "实际收到盒数(退货)不能为空", trigger: "blur" }])
        // }
        // if(this.form.aftTab == null || this.form.aftTab == ''){
        //   this.$set(this.rules,"aftTab",[{ required: true, message: "售后标签不能为空", trigger: "blur" }])
        // }
        // if(this.form.aftCheck == null || this.form.aftCheck == ''){
        //   this.$set(this.rules,"aftCheck",[{ required: true, message: "时间考核不能为空", trigger: "blur" }])
        // }
        if(this.form.aftSendStatus == null || this.form.aftSendStatus == ''){
          this.$set(this.rules,"aftSendStatus",[{ required: true, message: "发货物流状态不能为空", trigger: "blur" }])
        }
        if(this.form.aftOptResult == null || this.form.aftOptResult == ''){
          this.$set(this.rules,"aftOptResult",[{ required: true, message: "操作结果不能为空", trigger: "blur" }])
        }
      }else{
        this.form.aftHandleTime = null
        this.form.aftCheck = null
        // 清除指定校验规则 "aftReturnNum","aftCheck","aftReceiveNum", "aftTab",
        this.$refs["form"].clearValidate(["aftReturnPrice",  "aftSendStatus","aftOptResult"]);
        // 这行必须aftCheck: [],aftReturnNum: [],aftReceiveNum: [], aftTab: [],
        this.rules = { ...this.rules, aftReturnPrice: [],    aftSendStatus: [], aftOptResult: []  };
      }

    },
    handlePaste(event) {
      // 阻止默认的粘贴行为，以防粘贴板内容被自动插入
      event.preventDefault();

      // 获取粘贴板内容
      const clipboardData = event.clipboardData || window.clipboardData;
      let pastedData = clipboardData.getData('text');

      // 处理粘贴板内容，例如显示或修改输入框的值
      console.log('Pasted data:', pastedData);
      // 你可以在这里根据需要修改输入框的值，例如：
      // this.$refs.myInput.value = pastedData; // 如果你的输入框有ref="myInput"
      // 或者更新数据模型
      // this.inputValue = pastedData; // 假设你有一个data属性叫inputValue来绑定到输入框的v-model
    }
  }
};
</script>


<style>
.el-table .row1 {
  background: #FFFFE0;
}
.el-table .row2 {
  background: #EAFAF1;
}
.el-table .row3 {
  background: #EBF5FB;
}
.el-table .row4 {
  background: #FFFFE0;
}

.tableTitle {
  position: relative;
  margin: 0 auto;
  width: 600px;
  height: 1px;
  background-color: #121611;
  text-align: center;
  font-size: 16px;
  color: rgba(101, 101, 101, 1);
}
.midText {
  position: absolute;
  left: 50%;
  background-color: #ffffff;
  padding: 0 15px;
  transform: translateX(-50%) translateY(-50%);
}

.overflow {
  /* 一定要加宽度 */
  width: 100%;
  /* 文字的大小 */
  height: 20px;
  /* 将对象作为弹性伸缩盒子模型显示 */
  display: -webkit-box;
  /* 超出的文本隐藏 */
  overflow: hidden;
  /* 溢出用省略号 */
  text-overflow: ellipsis;
  /* 显示1行，控制显示的行数 */
  -webkit-line-clamp: 1;
  /* 从上到下垂直排列子元素（设置伸缩盒子的子元素排列方式) */
  -webkit-box-orient: vertical;
}
</style>
